package cn.mugutu.finance.dto;

import cn.mugutu.finance.domain.system.Department;
import lombok.Data;

import java.util.ArrayList;
import java.util.List;

@Data
public class DepartmentDto {
	
	private Long id;
	private String name;
	private String parentName;
	private Long parentId;
	

	public DepartmentDto(Department department) {
		this.id = department.getId();
		this.name = department.getName();
		this.parentName = department.getParent()!=null?department.getParent().getName():"/";
		this.parentId = department.getParent()!=null?department.getParent().getId():1L;
	}
	public static List<DepartmentDto> departmentListToDepartmentDtoList(List<Department> list){
		List<DepartmentDto> dds = new ArrayList<>();
		for (Department department : list) {
			DepartmentDto dd = new DepartmentDto(department);
			dds.add(dd);
		}
		return dds;
	}
}
